From f4d2d0e9a2159154e327a3f05b467824ae5e9e15 Mon Sep 17 00:00:00 2001 From: Charles Arnold Date: Thu, 2 Apr 2015 09:42:02 -0600 Subject: [PATCH] xentop: fix potential memory leak On a read failure the qstats buffer is not freed. Signed-off-by: Charles Arnold Acked-by: Ian Campbell --- tools/xenstat/libxenstat/src/xenstat_qmp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/xenstat/libxenstat/src/xenstat_qmp.c b/tools/xenstat/libxenstat/src/xenstat_qmp.c index c217b8e78b..2cb99e9a60 100644 --- a/tools/xenstat/libxenstat/src/xenstat_qmp.c +++ b/tools/xenstat/libxenstat/src/xenstat_qmp.c @@ -298,6 +298,7 @@ static int qmp_read(int qfd, unsigned char **qstats) while ((n = poll(pfd, POLLIN, 10)) > 0) { if (pfd[0].revents & POLLIN) { if ((n = read(qfd, buf, sizeof(buf))) < 0) { + free(*qstats); return 0; } ptr = realloc(*qstats, qsize+n+1); -- 2.30.2